package cn.tedu.tmall.passport.controller;

import cn.tedu.tmall.common.web.JsonResult;
import cn.tedu.tmall.passport.pojo.param.UserLoginParam;
import cn.tedu.tmall.passport.pojo.vo.UserLoginVO;
import cn.tedu.tmall.passport.service.IUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/passport")
@Slf4j
@Validated
@Tag(name="用户登录功能")
public class UserController {
    @Autowired
    private IUserService userService;
    @PostMapping("/reg")
    @Operation(summary = "注册功能")
    public JsonResult reg(@RequestParam String name,@RequestParam String password){
        return JsonResult.ok();
    }

    @PostMapping("login")
    @Operation(summary = "登录功能")
    public JsonResult login(@RequestBody @Validated UserLoginParam userLoginParam, HttpServletRequest httpServletRequest){
        UserLoginVO userLoginVO =userService.login(userLoginParam,httpServletRequest);
        return JsonResult.ok(userLoginVO);
    }
}
